package server

import "gitee.com/crack007/goose/gsutil"

type DefaultUdpSessionHandle struct {
	Session *Session
}

func (x *DefaultUdpSessionHandle) Init(session *Session) {
	x.Session = session
}

func (x *DefaultUdpSessionHandle) OnHandshake() bool {
	//TODO implement me
	panic("implement me")
}

func (x *DefaultUdpSessionHandle) OnConnect() {

}

func (x *DefaultUdpSessionHandle) OnMessage(data []byte) {

}

func (x *DefaultUdpSessionHandle) OnClose(err error) {

}

func (x *DefaultUdpSessionHandle) OnReadIdleTimeout() {

}

func (x *DefaultUdpSessionHandle) OnWriteIdleTimeout() {

}

func (x *DefaultUdpSessionHandle) OnIdleTimeout() {

}

func (x *DefaultUdpSessionHandle) GetSessionId() int64 {
	ip := int64(gsutil.IpUtil.IpToInt(x.Session.RemoteIp))
	port := int64(x.Session.RemotePort)
	return ip<<32 | port
}

func (x *DefaultUdpSessionHandle) OnConflict(newSession *Session) *Session {
	return newSession
}
